from Base import message, intersect, SS_VALID,SS_INVALID
from DRG import MDCA_DRG
def group(record):
    adrg_zd = []
    adrg_zd1 = ["Z93.000"]
    adrg_ss = ["96.7201"]
    adrg_ss1 = ["31.1x00x005","31.2100x001","31.2900x001","31.7400","31.7400x001","96.0400","96.5500"]
    dept_list = []

    if (intersect(record.zdList[1:], adrg_zd1) and intersect(record.ssList, adrg_ss)) or \
       (intersect(record.ssList, adrg_ss) and any(x in record.ssList for x in adrg_ss1)):
        if (intersect(record.zdList[1:], adrg_zd1) and intersect(record.ssList, adrg_ss)):
            message('符合AH2入组条件1，匹配规则：存在96.7201 呼吸机治疗[大于等于96小时]+其他诊断')
        else:
            message('符合AH2入组条件2，匹配规则：存在96.7201 呼吸机治疗[大于等于96小时]+手术或操作1')
            
        if MDCA_DRG.AH29_group(record):
            return 'AH29'
            
        return 'AH2'
    else:
        return ''